﻿package frEngine.shader.filters.fragmentFilters.extra
{
    import __AS3__.vec.*;
    import frEngine.shader.*;
    import frEngine.shader.filters.*;
    import frEngine.shader.filters.vertexFilters.def.*;

    public class InflateFilter extends FilterBase
    {
        private var outSize:Vector.<Number>;

        public function InflateFilter()
        {
            this.outSize = this.Vector.<Number>([3, 3, 1.4, 1]);
            super(FilterType.InflateFilter, FilterPriority.InflateFilter, null);
            return;
        }// end function

        override public function setRegisterParams(param1:Program3dRegisterInstance) : void
        {
            param1.getParamByName("{OutSize}", true).value = this.outSize;
            return;
        }// end function

        override public function get programeId() : String
        {
            return "InflateFilter";
        }// end function

        public function setLightStrength(param1:Number) : void
        {
            this.outSize[2] = param1;
            return;
        }// end function

        override public function createVertexCode(param1:Program3dRegisterInstance, param2:int) : String
        {
            var _loc_4:String = null;
            var _loc_3:* = new Array();
            _loc_3.push(new ToBuilderInfo("vc0", "{OutSize}", false, 1, this.outSize));
            _loc_3.push(new ToBuilderInfo("vf2", "{v_alphaValue}", false, 1));
            _loc_3.push(new ToBuilderInfo("vm0", FilterName.worldView, true, 4));
            _loc_4 = "";
            _loc_4 = _loc_4 + "m33           vt0.xyz  \t\t\t{T_VetextNormal}.xyz     vm0    \t\t\t\n";
            _loc_4 = _loc_4 + "nrm           vt0.xyz       \tvt0.xyz\t\t\t\t\t\t\t\t\t\t\t\n";
            _loc_4 = _loc_4 + "abs \t\t\t vt1.x\t\t \t\tvt0.z\t\t\t\t\t\t\t\t\t\t\t\n";
            _loc_4 = _loc_4 + "pow \t\t\t vt1.x\t\t \t\tvt1.x\t\t\t\t\t\t{OutSize}.y \t\t\n";
            _loc_4 = _loc_4 + "mul \t\t\t vt1.x\t\t \t\tvt1.x\t\t\t\t\t\t{OutSize}.z \t\t\n";
            _loc_4 = _loc_4 + "sat \t\t\t vt1.x\t\t \t\tvt1.x\t\t\t\t\t\t \t\t\t\t\t\n";
            _loc_4 = _loc_4 + "mov           vf2  \t\t\t\tvt1.x\t\t\t\t\t\t\t\t\t\t\t\n";
            _loc_4 = _loc_4 + "mul           vt0.xyz       \tvt0.xyz\t\t\t\t\t\tvc0.x\t\t\t\t\n";
            _loc_4 = _loc_4 + "m34           {output}.xyz  \t{output}      \t\t\t\tvm0    \t\t\t\t\n";
            _loc_4 = _loc_4 + "add           {output}.xyz  \tvt0.xyz      \t\t\t\t{output}    \t\t\n";
            _loc_4 = param1.toBuild(_loc_4, _loc_3);
            param1.OpType = ECalculateOpType.Proj;
            return _loc_4;
        }// end function

        override public function createFragmentColor(param1:Program3dRegisterInstance, param2:Boolean) : String
        {
            var _loc_3:* = new Array();
            _loc_3.push(new ToBuilderInfo("fc0", "{outColor}", false, 1, [1, 0, 0, 1]));
            var _loc_4:String = "";
            _loc_4 = _loc_4 + "mul\t ft0.x\t\t{output}.w \t\t\t{v_alphaValue}.x\t\n";
            _loc_4 = _loc_4 + "mul\t ft0.x\t\t ft0.x \t\t\t\t\t{outColor}.w\t\t\n";
            _loc_4 = _loc_4 + "mul {output}   ft0.x  \t\t\t\t{outColor} \t\t\n";
            _loc_4 = param1.toBuild(_loc_4, _loc_3);
            return _loc_4;
        }// end function

    }
}
